package com.xpalive.commons;

import com.xpalive.exception.BizException;
import org.apache.commons.lang3.StringUtils;

public final class BizAssert {

    private BizAssert() {
    }

    public static void privateConstructor() {
        throw new BizException("private constructor");
    }

    public static void notBlank(String string) {
        notBlank(string, "string can not be blank");
    }

    public static void notBlank(String string, String message) {
        if (StringUtils.isBlank(string)) {
            throw new BizException(message);
        }
    }

    public static void notNull(Object object) {
        notNull(object, "object can not be null");
    }

    public static void notNull(Object object, String message) {
        if (object == null) {
            throw new BizException(message);
        }
    }

    public static void isTrue(boolean expression) {
        isTrue(expression, "expression is false");
    }

    public static void isTrue(boolean expression, String message) {
        if (!expression) {
            throw new BizException(message);
        }
    }
}
